local hx__bingjuexing = fk.CreateSkill{
    name = "hx__bingjuexing",

    tags = {Skill.Compulsory},
}

hx__bingjuexing:addEffect(fk.AfterCardsMove,{
    can_trigger = function (self, event, target, player, data)
        if not player:hasSkill(hx__bingjuexing.name) or player:usedSkillTimes(hx__bingjuexing.name) > 4 or player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) > 0 then return end
        for _, move in ipairs(data) do
        if move.from == player and move.to ~= player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                return true
            end
          end
        end
      end
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:changeMaxHp(player,1)
        room:recover{
            who = player,
            num = 1,
            recoverBy = player,
            skillName = hx__bingjuexing.name
        }
        player:drawCards(3,hx__bingjuexing.name)
    end,
})

local spec = {
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__bingjuexing.name) and target and target == player and player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) > 0
    end,    
    on_cost = function (self, event, target, player, data)
        local room = player.room
        if not table.contains(player:getTableMark("hx__bingjuexing__type-turn"), data.card:getTypeString()) then
            room:addTableMarkIfNeed(player,"hx__bingjuexing__type-turn",data.card:getTypeString())
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        player:drawCards(8,hx__bingjuexing.name)
    end, 
}

hx__bingjuexing:addEffect(fk.CardUsing,spec)
hx__bingjuexing:addEffect(fk.CardResponding,spec)

hx__bingjuexing:addEffect(fk.DamageInflicted,{
    can_trigger = function (self, event, target, player, data)
       return player:hasSkill(hx__bingjuexing.name) and target and target:getMark("@hx__bingjuexing__bingdong") > 0 and player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) > 0
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        for _, v in ipairs(target:getAllSkills()) do
            room:invalidateSkill(target,v.name,"-turn",hx__bingjuexing.name)
        end
    end,
})

return hx__bingjuexing